<?php

class Application_Form_Registration extends Zend_Form
{
    public function init()
    {
      $this->setName('reg_form')
        ->setMethod('post');

      $name = new Zend_Form_Element_Text('first_name');
      $name->setAttrib('placeholder', 'Имя')
        ->addFilter(new Zend_Filter_StringTrim())
        ->setRequired(true);
      $this->addElement($name);

      $surname = new Zend_Form_Element_Text('last_name');
      $surname->setAttrib('placeholder', 'Фамилия')
        ->addFilter(new Zend_Filter_StringTrim())
        ->setRequired(true);
      $this->addElement($surname);

      $email = new Zend_Form_Element_Text('email');
      $email->setAttrib('placeholder', 'email')
        ->addValidator(new Zend_Validate_Db_NoRecordExists(array(
            'table' => 'users',
            'field' => 'email'
          )
        ))
        ->addValidator(new Zend_Validate_EmailAddress())
        ->setRequired(true);
      $this->addElement($email);

      $password = new Zend_Form_Element_Password('password');
      $password->setAttrib('placeholder', 'Пароль')
        ->setRequired(true)
        ->addValidator('StringLength', false, array('min' => 6))
        ->addFilter(new Zend_Filter_StringTrim())
        ->addValidator(new Zend_Validate_NotEmpty());
      $this->addElement($password);

      $password_conf = new Zend_Form_Element_Password('password_conf');
      $password_conf->setAttrib('placeholder', 'Пароль')
        ->setRequired(true)
        ->addFilter(new Zend_Filter_StringTrim())
        ->addValidator(new Zend_Validate_Identical('password'));
      $this->addElement($password_conf);

      $submit = new Zend_Form_Element_Submit('submit');
      $submit->setLabel('Регистрация');
      $this->addElement($submit);

    }

}

